package cn.akwangl.controller;

import cn.akwangl.common.Result;
import cn.akwangl.pojo.LoginQuery;
import cn.akwangl.service.LoginService;
import cn.akwangl.service.impl.LocalLoginServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录
 *
 * @author youyongkun
 * @date 2022/5/17 14:23
 */
@RestController
public class LoginController {

    private LoginService loginService;

    @Autowired
    @Qualifier(LocalLoginServiceImpl.BEAN_NAME)
    public void setLoginService(LoginService loginService) {
        this.loginService = loginService;
    }

    @PostMapping("/login")
    public Result login(@RequestBody LoginQuery loginQuery) {
        String token = loginService.login(loginQuery.getUsername(), loginQuery.getPwd());
        return Result.success(token);
    }
}
